package com.xh.rufongwallpaper.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;
import java.util.List;

/**
 * 上传配置类
 */
@Configuration
@ConfigurationProperties(prefix = "application.upload")
@Data
public class UploadConfig {

    /**
     * 上传基础路径
     */
    private String basePath = "uploads";

    /**
     * 壁纸上传配置
     */
    private WallpaperUpload wallpaper = new WallpaperUpload();

    /**
     * 静态资源位置
     */
    private String staticLocations;

    /**
     * 壁纸上传配置类
     */
    @Data
    public static class WallpaperUpload {
        /**
         * 壁纸上传路径
         */
        private String path = "uploads/wallpapers";

        /**
         * 允许的图片类型
         */
        private String allowedTypes = "image/jpeg,image/png,image/jpg,image/gif";

        /**
         * 缩略图宽度
         */
        private int thumbnailWidth = 400;

        /**
         * 缩略图质量
         */
        private double thumbnailQuality = 0.8;

        /**
         * 获取允许的图片类型列表
         */
        public List<String> getAllowedTypesList() {
            return Arrays.asList(allowedTypes.split(","));
        }
    }
} 